package com.kitchen.ui.controls.stock
{
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;

	public class StockLoad extends Sprite
	{
		public var totalLoade:Number;
		public var loaded:Number;
		private var lmask:Shape;
		public var h:Number;
		public var w:Number;
		
		public function StockLoad(mainSkin:BitmapData)
		{
			super();
			this.layout(mainSkin);
		}
		
		private function layout(mainSkin:BitmapData):void{
			var border:StockLoadBorderIcon = new StockLoadBorderIcon(mainSkin);
			this.addChild(border);
			var process:Sprite = new Sprite();
			var pIcon:StockProcessIcon = new StockProcessIcon(mainSkin);
			process.addChild(pIcon);
			this.lmask = new Shape();
			this.lmask.graphics.beginFill(0xffffff, 1);
			this.lmask.graphics.drawRect(0, 0, pIcon.w, pIcon.h);
			this.lmask.graphics.endFill();
			this.w = this.lmask.width = pIcon.w;
			this.h = this.lmask.height = pIcon.h;
			process.mask = this.lmask;
			this.lmask.x = -this.lmask.width;
			process.addChild(this.lmask);
			process.x = 4;
			this.addChild(process);
		}
		
		public function setLoadedRate(rate:Number):void{
			if(rate <= 1){
				var ox:int = Math.ceil((1-rate)*this.lmask.width);
				this.lmask.x = -ox;
			}
		}
	}
}